<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>streamWrapper 类</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="php-user-filter.oncreate.html">« php_user_filter::onCreate</a></li>
      <li style="float: right;"><a href="streamwrapper.construct.html">streamWrapper::__construct »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.stream.html">Stream</a></li>
    <li>streamWrapper 类</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.streamwrapper" class="reference">

 <h1 class="title">streamWrapper 类</h1>
 

 <div class="partintro"><p class="verinfo">(PHP 4 &gt;= 4.3.2, PHP 5, PHP 7, PHP 8)</p>


  <div class="section" id="streamwrapper.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    允许实现自定义协议处理程序和流，以便与其它文件系统函数（比如 <span class="function"><a href="function.fopen.html" class="function">fopen()</a></span>、
    <span class="function"><a href="function.fread.html" class="function">fread()</a></span> 等）一起使用。
   </p>
   <blockquote class="note"><p><strong class="note">注意</strong>: 
    <p class="para">
     这<em class="emphasis">不是</em>真实的类，只是如何定义协议的原型类。
    </p>
   </p></blockquote>
   <blockquote class="note"><p><strong class="note">注意</strong>: 
    <p class="para">
     不使用此处描述的方法而使用其它方式可能会导致未定义行为。
    </p>
   </p></blockquote>
   <p class="para">
    一旦流函数尝试访问与其关联的协议，就会初始化此类的实例。
   </p>
  </div>


  <div class="section" id="streamwrapper.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass"></div>


    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <span class="replaceable">streamWrapper</span>
     </span>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 属性 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">public</span>
     <span class="type">resource</span>
      <var class="varname"><a href="class.streamwrapper.html#streamwrapper.props.context">$<var class="varname">context</var></a></var>;</div>


    
    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.construct.html" class="methodname">__construct</a></span>()</div>

    <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.dir-closedir.html" class="methodname">dir_closedir</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.dir-opendir.html" class="methodname">dir_opendir</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.dir-readdir.html" class="methodname">dir_readdir</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.dir-rewinddir.html" class="methodname">dir_rewinddir</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.mkdir.html" class="methodname">mkdir</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.rename.html" class="methodname">rename</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$path_from</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$path_to</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.rmdir.html" class="methodname">rmdir</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.stream-cast.html" class="methodname">stream_cast</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$cast_as</code></span>): <span class="type">resource</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.stream-close.html" class="methodname">stream_close</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.stream-eof.html" class="methodname">stream_eof</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.stream-flush.html" class="methodname">stream_flush</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.stream-lock.html" class="methodname">stream_lock</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$operation</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.stream-metadata.html" class="methodname">stream_metadata</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$option</code></span>, <span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.stream-open.html" class="methodname">stream_open</a></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$mode</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter reference">&$opened_path</code></span><br>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.stream-read.html" class="methodname">stream_read</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$count</code></span>): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.stream-seek.html" class="methodname">stream_seek</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$offset</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$whence</code> <span class="initializer"> = SEEK_SET</span></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.stream-set-option.html" class="methodname">stream_set_option</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$option</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$arg1</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$arg2</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.stream-stat.html" class="methodname">stream_stat</a></span>(): <span class="type"><span class="type">array</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.stream-tell.html" class="methodname">stream_tell</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.stream-truncate.html" class="methodname">stream_truncate</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$new_size</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.stream-write.html" class="methodname">stream_write</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.unlink.html" class="methodname">unlink</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.url-stat.html" class="methodname">url_stat</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code></span>): <span class="type"><span class="type">array</span>|<span class="type"><span class="type false">false</span></span></span></div>

    <div class="destructorsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="streamwrapper.destruct.html" class="methodname">__destruct</a></span>()</div>

   }</div>


  </div>

  

  <div class="section" id="streamwrapper.props">
   <h2 class="title">属性</h2>
   <dl>
    
     <dt id="streamwrapper.props.context">资源 <var class="varname">context</var></dt>

     <dd>

      <p class="para">
       当前 <a href="context.html" class="link">context</a>，或者没有 context 传递给调用函数，则为 <strong><code>null</code></strong>。
      </p>
      <p class="para">
       使用 <span class="function"><a href="function.stream-context-get-options.html" class="function">stream_context_get_options()</a></span> 解析 context。
      </p>
      <blockquote class="note"><p><strong class="note">注意</strong>: 
       <p class="para">
        此属性<em class="emphasis">必须</em>是 public，以便 PHP 可以使用使用实际的 context 资源填充它。
       </p>
      </p></blockquote>
     </dd>

    
   </dl>

  </div>


 <div class="section">
  <h2 class="title">参见</h2>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><a href="stream.streamwrapper.example-1.html" class="xref">示例类注册为流封装器</a></li>
    <li class="member"><span class="function"><a href="function.stream-wrapper-register.html" class="function">stream_wrapper_register()</a></span></li>
    <li class="member"><span class="function"><a href="function.stream-wrapper-unregister.html" class="function">stream_wrapper_unregister()</a></span></li>
    <li class="member"><span class="function"><a href="function.stream-wrapper-restore.html" class="function">stream_wrapper_restore()</a></span></li>
   </ul>
  </p>
 </div>

 </div>

 



















































































































































 




























<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="streamwrapper.construct.html">streamWrapper::__construct</a> — Constructs a new stream wrapper</li><li><a href="streamwrapper.destruct.html">streamWrapper::__destruct</a> — Destructs an existing stream wrapper</li><li><a href="streamwrapper.dir-closedir.html">streamWrapper::dir_closedir</a> — Close directory handle</li><li><a href="streamwrapper.dir-opendir.html">streamWrapper::dir_opendir</a> — Open directory handle</li><li><a href="streamwrapper.dir-readdir.html">streamWrapper::dir_readdir</a> — Read entry from directory handle</li><li><a href="streamwrapper.dir-rewinddir.html">streamWrapper::dir_rewinddir</a> — Rewind directory handle</li><li><a href="streamwrapper.mkdir.html">streamWrapper::mkdir</a> — Create a directory</li><li><a href="streamwrapper.rename.html">streamWrapper::rename</a> — Renames a file or directory</li><li><a href="streamwrapper.rmdir.html">streamWrapper::rmdir</a> — Removes a directory</li><li><a href="streamwrapper.stream-cast.html">streamWrapper::stream_cast</a> — Retrieve the underlaying resource</li><li><a href="streamwrapper.stream-close.html">streamWrapper::stream_close</a> — Close a resource</li><li><a href="streamwrapper.stream-eof.html">streamWrapper::stream_eof</a> — Tests for end-of-file on a file pointer</li><li><a href="streamwrapper.stream-flush.html">streamWrapper::stream_flush</a> — Flushes the output</li><li><a href="streamwrapper.stream-lock.html">streamWrapper::stream_lock</a> — Advisory file locking</li><li><a href="streamwrapper.stream-metadata.html">streamWrapper::stream_metadata</a> — Change stream metadata</li><li><a href="streamwrapper.stream-open.html">streamWrapper::stream_open</a> — Opens file or URL</li><li><a href="streamwrapper.stream-read.html">streamWrapper::stream_read</a> — Read from stream</li><li><a href="streamwrapper.stream-seek.html">streamWrapper::stream_seek</a> — Seeks to specific location in a stream</li><li><a href="streamwrapper.stream-set-option.html">streamWrapper::stream_set_option</a> — Change stream options</li><li><a href="streamwrapper.stream-stat.html">streamWrapper::stream_stat</a> — Retrieve information about a file resource</li><li><a href="streamwrapper.stream-tell.html">streamWrapper::stream_tell</a> — Retrieve the current position of a stream</li><li><a href="streamwrapper.stream-truncate.html">streamWrapper::stream_truncate</a> — Truncate stream</li><li><a href="streamwrapper.stream-write.html">streamWrapper::stream_write</a> — Write to stream</li><li><a href="streamwrapper.unlink.html">streamWrapper::unlink</a> — Delete a file</li><li><a href="streamwrapper.url-stat.html">streamWrapper::url_stat</a> — Retrieve information about a file</li></ul>
</div>
</div></div></body></html>